package open.tech.dawn.web.core.properties;

import open.tech.dawn.web.util.MD5Util;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * jwt相关配置
 */
@Configuration
@ConfigurationProperties(prefix = JwtProperties.JWT_PREFIX)
public class JwtProperties {

    /**
     * 请求头
     */
    public static final String REQUEST_HEADER = "Authorization";

    /**
     * 请求头前缀
     */
    public static final String HEADER_BODY_PREFIX = "Bearer";


    public static final String JWT_PREFIX = "dawn.jwt";

    private String secret = "DawnMAIINAL8884F7DE527FAD";

    /**
     * 有效期(单位:秒)
     */
    private Integer expirationSeconds = 604800;

    private String md5Key = "DawnMAIINAL8882F71E827FAD";

    public String getSecret() {
        return MD5Util.encrypt(secret);
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public Integer getExpirationSeconds() {
        return expirationSeconds;
    }

    public void setExpirationSeconds(Integer expirationSeconds) {
        this.expirationSeconds = expirationSeconds;
    }

    public String getMd5Key() {
        return MD5Util.encrypt(md5Key);
    }

    public void setMd5Key(String md5Key) {
        this.md5Key = md5Key;
    }
}
